package com.example.demo.test;

import com.alibaba.fastjson.JSON;
import com.example.demo.utils.Utils;
import com.example.demo.utils.WangyiUtils;
import net.sf.json.JSONObject;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.concurrent.TimeUnit;

//B站领辣条
public class LingLaTiao {


    public static void main(String[] args) throws Exception {


        while (true) {
            int i = Utils.lingLaTiao(2810351);
            System.out.println(i);
            Thread.sleep(1000 * 60 * 5);
        }


    }


    //领辣条
    @Test
    public void test2() throws Exception {

        int count = 0;
        while (true) {
            //读
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("D:\\cookie\\vaildnumber.txt"));
            int o = (int) objectInputStream.readObject();
            System.out.println(o + "第" + count + "次");
            //抽
            int i1 = o;
            int i = Utils.lingLaTiao(i1);
            //抽完写
            //写完睡
            System.out.println("开睡");
            Thread.sleep(1000 * 60);
        }


    }

    //开启header
    @Test
    public void headertest() throws Exception {
        String k1 = " header.put";
        String s = ":authority: api.bilibili.com\n" +
                ":method: POST\n" +
                ":path: /x/v2/reply/add\n" +
                ":scheme: https\n" +
                "accept: application/json, text/javascript, */*; q=0.01\n" +
                "accept-encoding: gzip, deflate, br\n" +
                "accept-language: zh-CN,zh;q=0.9,zh-TW;q=0.8\n" +
                "content-length: 99\n" +
                "content-type: application/x-www-form-urlencoded; charset=UTF-8\n" +
                "cookie: sid=izrhxjpb; _uuid=9B1EBC53-24DE-3C3B-5478-C7B04BE21BFA39066infoc; buvid3=41EFFC96-BFEA-4264-96FE-6C4594B8888453923infoc; LIVE_BUVID=AUTO3115929677890054; bp_video_offset_221749181=404765698027349726; bp_t_offset_221749181=404766372336171715; CURRENT_FNVAL=16; rpdid=|(um~uYJJm)m0J'ulmJ|)Jm|Y; DedeUserID=619772228; DedeUserID__ckMd5=e9b2d53e131edb2b; SESSDATA=1d509e2c%2C1609413643%2Cb3f9e*71; bili_jct=2d1cd64f8d95d254d3dc44077a7df701; CURRENT_QUALITY=0; PVID=2; bp_video_offset_619772228=409560225856138278; bp_t_offset_619772228=409560225856138278; dy_spec_agreed=1; bfe_id=1bad38f44e358ca77469025e0405c4a6\n" +
                "origin: https://t.bilibili.com\n" +
                "referer: https://t.bilibili.com/topic/name/%E8%BD%AC%E5%8F%91%E6%8A%BD%E5%A5%96/feed\n" +
                "sec-fetch-dest: empty\n" +
                "sec-fetch-mode: cors\n" +
                "sec-fetch-site: same-site\n" +
                "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36";
        Utils.getMap(k1, s);
    }

    //开启data
    @Test
    public void datatest() throws Exception {
        String k1 = "connect.data";
        String s = "oid: 409508583164977015\n" +
                "type: 17\n" +
                "message: 555\n" +
                "plat: 1\n" +
                "jsonp: jsonp\n" +
                "csrf: 2d1cd64f8d95d254d3dc44077a7df701";
        Utils.getMap(k1, s);
    }

    @Test
    public void test3() throws Exception {
        FileOutputStream fileOutputStream = new FileOutputStream("D:\\excel\\latiaonumber.txt");
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
        objectOutputStream.writeObject(2828171);

    }

    @Test
    public void test4() throws Exception {
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("D:\\excel\\latiaonumber.txt"));
        int o = (int) objectInputStream.readObject();
        System.out.println(o);

    }

    @Test
    public void test5() throws Exception {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "D:\\ChromeDriver\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("download.default_directory", "D:\\360MoveData\\Users\\疯子似的少年\\Desktop\\自媒体");
        options.setExperimentalOption("prefs", prefs);
        ChromeDriver webDriver = new ChromeDriver(options);
        Set<Cookie> read = WangyiUtils.read();
        String url = "https://jianwai.youdao.com/audioTransfer";
        webDriver.get(url); //
    }

}
